package snuggle.jabber.listeners;

import org.apache.log4j.Logger;
import org.jivesoftware.smack.Chat;
import org.jivesoftware.smack.MessageListener;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.packet.Message;

import snuggle.jabber.bot.SnuggleBot;

public class MessageList implements MessageListener {

	private static Logger logger = Logger.getLogger(MessageList.class);

	
	public MessageList() {
		super();
	}

	@Override
	public void processMessage(Chat chat, Message message) {
		if(null != message && null != message.getBody())
			try {
				SnuggleBot.getMessageUtils().parseMessage(chat.getParticipant(), message);
			} catch (NotConnectedException e) {
				logger.error(e.getMessage());
			}
	}

}
